<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    <link rel="icon" th:href="@{https://v3.bootcss.com/favicon.ico}">
    <title>用户分页</title>
    <link rel="stylesheet" th:href="@{/css/dashboard.css}">
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/css/dashboard.css}">
</head>
<body>
<div th:insert="~{commons/commons::topbar}"></div>
<div class="container-fluid">
    <div class="row">

        <div
                th:insert="~{commons/commons::sidebar(active = 'userpage.html')}"></div>


        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h1 class="page-header">用户分页</h1>
            <div class="row placeholders"></div>
            <h2 class="sub-header">
                <a class="btn btn-sm btn-success" th:href="@{/user/toAdd}">新增用户</a>

            </h2>
            <div class="table-responsive">
                <table class="table table-striped">
                    <thead>
                    <!-- 表头 -->
                    <tr>
                        <th>编号</th>
                        <th>姓名</th>
                        <th>邮箱</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <!-- 身体   遍历取值 -->
                    <tr th:each="user : ${users}">
                        <td th:text="${user.id}"></td>
                        <td th:text="${user.lastName}"></td>
                        <td th:text="${user.email}"></td>

                        <td><a class="btn btn-sm btn-primary"
                               th:href="@{/user/toEdit/} + ${user.id}">编辑</a> <a
                                class="btn btn-sm btn-danger"
                                th:href="@{/user/delete/} + ${user.id}">删除</a></td>
                    </tr>
                    </tbody>
                </table>
            </div>

            <div class="modal-footer no-margin-top">
                <ul class="pagination pull-right no-margin">

                    <!-- 首页 -->
                    <li><a th:href="'/user/findAll?pageNum=0'">首页</a></li>

                    <!-- 上一页 -->
                    <li th:if="${users.hasPrevious()}"><a
                            th:href="'/user/findAll?pageNum=' + ${users.previousPageable().getPageNumber()}"
                            th:text="上一页"></a></li>

                    <!-- 中间页 -->
                    <li
                            th:each="pageNum:${#numbers.sequence(0, users.getTotalPages() - 1)}">
                        <a th:href="'/user/findAll?pageNum=' + ${pageNum}"
                           th:if="${pageNum ne users.pageable.getPageNumber()}"
                           th:text="${pageNum + 1}"></a> <a
                            th:href="'/user/findAll?pageNum=' + ${pageNum}"
                            th:if="${pageNum eq users.pageable.getPageNumber()}"
                            th:style="'font-weight:bold;background: #6faed9;'"
                            th:text="${pageNum + 1}"></a>
                    </li>

                    <!-- 下一页 -->
                    <li th:if="${users.hasNext()}"><a
                            th:href="'/user/findAll?pageNum=' + ${users.nextPageable().getPageNumber()}"
                            th:text="下一页"></a></li>

                    <!-- 尾页 -->
                    <li><a
                            th:href="'/user/findAll?pageNum=' + ${users.getTotalPages() - 1}">尾页</a>
                    </li>

                </ul>
            </div>
        </div>
    </div>
</div>
</body>
</html>